package com.shuoyue.ycgk.ui.mine.mok;

import com.shuoyue.ycgk.base.BaseModel;
import com.shuoyue.ycgk.base.BasePresenter;
import com.shuoyue.ycgk.base.BaseResult;
import com.shuoyue.ycgk.base.BaseView;
import com.shuoyue.ycgk.entity.Mok;
import com.shuoyue.ycgk.net.RetrofitClient;
import com.shuoyue.ycgk.net.base.ApiSubscriber;
import com.shuoyue.ycgk.net.gsondefaultadapter.Optional;

import java.util.List;

import io.reactivex.Observable;

public interface MyMokContract {
      interface View extends BaseView {
        void setMoks(List<Mok> num);
    }

      class Presenter extends BasePresenter<View> {
        Model model = new Model();

        public void getMyMok() {
            apply(model.getMyMok())
                    .subscribe(new ApiSubscriber<Optional<List<Mok>>>(mView, this) {
                        @Override
                        public void onNext(Optional<List<Mok>> lessonProcessOptional) {
                            super.onNext(lessonProcessOptional);
                            mView.setMoks(lessonProcessOptional.getIncludeNull());
                        }

                    });
        }
    }

    class Model extends BaseModel {
        Observable<BaseResult<List<Mok>>> getMyMok() {
            return RetrofitClient.getInstance().getApi().getMyMok();
        }
    }
}
